package com.legleg.handler;

import com.legleg.data.Album;
import com.legleg.db.AlbumDao;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 12-12-29
 * Time: 下午1:30
 * To change this template use File | Settings | File Templates.
 */
public class AlbumHandler {
    private static AlbumHandler instance;
    private static Object lock = new Object();
    public static AlbumHandler getInstance() {
        if(instance == null)
        {
            synchronized (lock){
                instance = new AlbumHandler();
            }
        }
        return instance;
    }

    public AlbumHandler() {
    }

    public boolean ifCrawled(Album album){
        return AlbumDao.ifCrawled(album);
    }

    public long insert(Album album){
        return AlbumDao.insert(album);
    }

    public int update(Album album){
        return AlbumDao.update(album);
    }

    public List<Album> getRefresh(int page,int pagesize){
        return AlbumDao.queryRefresh(pagesize*(page-1),pagesize);
    }

    public List<Album> getHot(int page,int pagesize){
        return AlbumDao.queryHot(pagesize*(page-1),pagesize);
    }

    public List<Album> queryByTag(String tag,int page,int pagesize){
        return AlbumDao.queryByTag(tag,pagesize*(page-1),pagesize);
    }
    
    public Album findById(long id){
        return AlbumDao.findById(id);
    }
    
    public List<String> queryAllTags(){
        return AlbumDao.queryAllTags();
    }
}
